package com.stadium.common.enums;

public enum ModuleEnum {

    ASSOCIATION("1", "组织模块操作"),

    LEAGUE("2", "联赛模块操作"),

    TEAM("3", "球队模块操作"),

    SCHEDULE("4", "比赛模块操作"),

    ASSOCIATION_USER("5", "组织人员操作"),

    LEAGUE_TEAM("6", "球队联赛关系模块操作"),

    REFEREE_SCHEDULE("7", "裁判员比赛关系模块操作"),

    TEAM_USER("8", "球队人员关系模块操作"),

    UNKNOWN("0", "未知");
    private String code;
    private String name;

    ModuleEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static ModuleEnum getModuleByCode(Integer code) {
        for (ModuleEnum moduleEnum : ModuleEnum.values()) {
            if (code.equals(moduleEnum.getCode())) {
                return moduleEnum;
            }
        }
        return ModuleEnum.UNKNOWN;
    }

    public static ModuleEnum getModuleByName(String name) {
        for (ModuleEnum moduleEnum : ModuleEnum.values()) {
            if (name.equals(moduleEnum.getName())) {
                return moduleEnum;
            }
        }
        return ModuleEnum.UNKNOWN;
    }
}
